<script>
    function setConfig(configValue) {
        document.getElementById('config').value = configValue; 
        if(configValue == "delete") {
            document.getElementById('regcode').value = "delete";
            var confirmValue = confirm("정말 삭제하겠습니까?"); 
            if(confirmValue) {
                document.coursefrm.submit();
            } else {
                alert('삭제 취소되었습니다.');
                return false;
            }
        }
        return true;
    }
    
    function paymentCheck() {
        var node = document.getElementById('price');
        var radio = document.coursefrm.paymentcheck; 
        var check = '0'; 
        if(node.value > 0) {
            check = '1'; 
        }
        for(var i=0; i<radio.length; i++) {
            if(radio[i].value == check) {
                radio[i].checked = 'checked'; 
            } 
        }
        return true;
    }

    function _renderDesc() {
        var _year = document.coursefrm.year.value;
        var _month = document.coursefrm.month.value;
        var _weeks = document.coursefrm.weekArray.value; 
        var _starttime = parseInt(document.coursefrm.starttime.value);
        var _endtime = _starttime+1;
        var _ampm = "오전";
        if(_starttime > 12) {
            _ampm = "오후";
            _starttime -= 12; 
        }
        var _eampm = "오전";
        if(_endtime > 12) {
            _endtime = _endtime-12; 
            if(_ampm == "오전") {
                _eampm = "오후";
            }
        }
        var _msg = _year + "년 "+_month+"월 ("+_weeks+" / "+" "+_ampm+" "+_starttime+ '시 ~ ' + _eampm +" "+ _endtime + '시)';
        document.getElementById('timeset').innerHTML = _msg; 
    }
</script>
<form enctype="multipart/form-data" method="POST" name="coursefrm">
<input type="hidden" name="MAX_FILE_SIZE" value="1000000">
<input type="hidden" id="config" name="config" value="" />
<input type="hidden" id="regcode" name="regcode" value="{regcode}" />
<input type="hidden" name="attachfile" value="{data.attachfile}" />
<input type="hidden" name="bannerfile" value="{data.bannerfile}" />
<input type="hidden" name="moviefile" value="{data.moviefile}" />
<input type="hidden" name="datano" value="{data.no}" />
<input type="hidden" name="year" value="{data.year}" />
<input type="hidden" name="month" value="{data.month}" />
<input type="hidden" name="starttime" value="{data.starttime}" />
<input type="hidden" name="weekArray" value="{weekArray}" />
<table width="100%" cellspacing="0" cellpadding="0" border="0" background="images/sub_bg.gif">
<tbody><tr>
<td><table width="823" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td background="images/sub_bg_title.gif"><img width="234" height="70" border="0" src="images/sub_title_business.gif"/></td>
</tr>
</tbody></table></td>
</tr>
<tr>
<td valign="top" height="40"><table width="823" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td><img width="1" height="1" src="images/1blank.gif"/></td>
<td width="81" bgcolor="#000000" align="right"><a href="./teacher.php?add"><img width="69" height="24" border="0" src="images/sub_business_01.gif"/></a></td>
<td width="26" bgcolor="#000000"><img width="26" height="24" src="images/sub_menu_line.gif"/></td>
<td width="3" bgcolor="#000000"><a href="./bookManageDetail.php?add"><img width="51" height="24" border="0" src="images/sub_business_02.gif"/></a></td>
<td width="26" bgcolor="#000000"><img width="26" height="24" src="images/sub_menu_line.gif"/></td>
<td width="66" bgcolor="#000000"><a href="./courseManageDetail.php?add"><img width="54" height="24" border="0" src="images/sub_business_03.gif"/></a></td>
</tr>
</tbody></table></td>
</tr>
<tr>
<td><table width="823" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td width="30" valign="top"><img width="1" height="1" src="images/1blank.gif"/></td>
<td valign="top" height="40"><img width="168" height="19" src="images/sub_business_03_title.gif"/></td>
</tr>
<tr>
<td valign="top"><img width="1" height="1" src="images/1blank.gif"/></td>
<td valign="top"><table width="100%" cellspacing="0" cellpadding="0" border="0">
<tbody><tr>
<td><table width="780" rules="rows" frame="hsides" cellspacing="0" cellpadding="3" bordercolor="#cccccc" border="2" style="border-collapse: collapse;" class="font">
<tbody><tr>
<td><div align="left">강의 코드</div></td>
<td><div align="left">
<input type="text" maxlength="8" size="8" value="ka-{data.no}"  class="font" name="code" disabled="disabled" style="background-color:#E8E8E8"/>
*자동 발행 </div></td>
</tr>
<tr>
<td width="130"><div align="left">강의명</div></td>
<td><div align="left">
<input type="text" maxlength="15" size="15" value="{data.name}" id="textfield2" class="font" name="name"/>
</div></td>
</tr>
<tr>
<td><div align="left">선생님 선택</div></td>
<td><div align="left">
<select id="select7" class="font" name="teacher">
<option>--선택해 주세요--</option>
{__teachers}
</select>
</div></td>
</tr>
<tr>
<td><div align="left">교재 선택</div></td>
<td><div align="left">
<select id="cate1" name="cate1"></select>
<select id="cate2" name="cate2"></select>
<select id="cate3" name="cate3"></select>
<select id="cate4" name="cate4"></select>
</div>
</td>
</tr>
<tr>
<td><div align="left">시간 설정</div></td>
<td><div align="left"> 
<span class="timeset" id="timeset">
<!--{? data.starttime   }-->
<script language="javascript">
    _renderDesc();
</script>
<!--{/}-->
</span>
<a href="#"><img width="105" height="23" border="0" align="absmiddle" onclick="javascript:newWindow('pop_timetable.html?','timetable','420', '220', 'true')" alt="" src="images/but_makelist_blue.gif"/></a></div></td>
</tr>
<tr>
<td><div align="left">강의 정원</div></td>
<td><div align="left">
<input type="text" maxlength="4" size="4" value="{data.perlimit}" class="font" name="perlimit"/>
</div></td>
</tr>
<tr>
<td><div align="left">강의 레벨</div></td>
<td><div align="left">
<select class="font" name="level">
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
</div></td>
</tr>
<tr>
<td><div align="left">수강료</div></td>
<td><div align="left">
<input type="text" maxlength="10" size="10" value="{data.price}" class="font" name="price" id="price" onChange="javascript:paymentCheck();"/>
원</div></td>
</tr>
<tr>
<td><div align="left">유/무료</div></td>
<td><div align="left">유료
<label>
<input type="radio" value="1" name="paymentcheck" onclick="javascript:paymentCheck();" />
</label>
/ 무료
<input type="radio" value="0" name="paymentcheck" onclick="javascript:paymentCheck();" />
(입력하신 수강료에 따라 자동 선택됩니다)

</div></td>
</tr>
<tr>
<td><div align="left">선생님 강의 내용</div></td>
<td><div align="left">
<label/>
<label>
<textarea id="textfield20" rows="10" cols="50" name="contents"/>{data.contents}</textarea>
</label>
<br/>
* 텍스트 및 HTML 코딩 가능 </div></td>
</tr>
<tr>
<td><div align="left">첨부파일</div></td>
<td><div align="left">
<label/>
<input type="file" class="font" name="attach"/>
<!--{? data.attachfile }-->
<br/>
현재 등록된 파일 : <a href="../data/courseAttach/<?php echo urlencode({data.attachfile}); ?>">{data.attachfile}</a>
<input type="checkbox" name="attachfiledelete">삭제</input>
<!--{/}-->
</div></td>
</tr>
<tr>
<td><div align="left">배너파일</div></td>
<td><div align="left">
<label/>
<input type="file" class="font" name="banner"/>
<!--{? data.bannerfile }-->
<br/>
현재 등록된 파일 : <a href="../data/courseBanner/<?php echo urlencode({data.bannerfile}); ?>">{data.bannerfile}</a>
<input type="checkbox" name="bannerfiledelete">삭제</input>
<!--{/}-->
</div></td>
</tr>
<tr>
<td><div align="left">배너링크</div></td>
<td><div align="left">
<input type="text" name="link" value="{data.link}" />
</div></td>
</tr>
<tr>
<td><div align="left">동영상</div></td>
<td><div align="left">
<label/>
<input type="file" class="font" name="movie"/>
<!--{? data.moviefile }-->
<br/>
현재 등록된 파일 : <a href="../data/courseMovie/<?php echo urlencode({data.moviefile}); ?>">{data.moviefile}</a>
<input type="checkbox" name="moviefiledelete">삭제</input>
<!--{/}-->
</div></td>
</tr>
<tr>
<td><div align="left">강의 상태 선택</div></td>
<td>
접수 대기
<!--{? data.check}-->
<input type="radio" value="0" name="check"/> / 접수시작
<input type="radio" value="1" checked="checked" name="check"/>
<!--{:}-->
<input type="radio" value="0" checked="checked" name="check"/> / 접수시작
<input type="radio" value="1" name="check"/>
<!--{/}-->
</div></td>
</tr>
</tbody></table></td>
</tr>
<tr>
<td> </td>
</tr>
<tr>
<td>
<button type=submit onClick="javascript:setConfig('add');" name="submit_add">{type} 완료 후 추가등록</button>&nbsp;
<button type=submit onClick="javascript:setConfig('list');" name="submit_list">{type} 완료</button>&nbsp;
<button type=reset>취소</button>&nbsp;
<!--{? type == "수정" }-->
<button type=button onClick="javascript:setConfig('delete');" name="submit_delete">상품 삭제</button>
<!--{/}-->
</tr>
</tbody></table></td>
</tr>
</tbody></table></td>
</tr>
</tbody></table>
</form>
